Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation of RF predictions with cosZD, for homogeneous performance #1320

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

moralejo
Copy link
Collaborator

@moralejo moralejo commented Nov 27, 2024

This should solve the issue of RF "performance jumps" at high zenith angles, when the pointing goes through the middle points between training nodes. See #1317

NOTE: this is a different implementation of the interpolation approach proposed by @gabemery, see branch https://github.com/cta-observatory/cta-lstchain/tree/dl2_RF_interpolate)

If the interpolation option is activated we call the RF predictors twice, for each of the two closest MC training nodes, then interpolate (or extrapolate) the values to the actual telescope pointing for each event.

Currently the training sample pointings are obtained from the path to the training sample(provided via config file). A better solution would be to add to the .sav files an array with the zenith and azimuth values of the MC training nodes.

to avoid jumps when using RFs trained on a discrete set of pointings
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 44.82759% with 48 lines in your changes missing coverage. Please review.

Project coverage is 73.30%. Comparing base (9aaa78b) to head (324a8c6).
Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
lstchain/reco/dl1_to_dl2.py 25.00% 45 Missing ⚠️
lstchain/scripts/lstchain_dl1_to_dl2.py 88.88% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1320      +/-   ##
==========================================
- Coverage   73.52%   73.30%   -0.22%     
==========================================
  Files         134      134              
  Lines       14215    14308      +93     
==========================================
+ Hits        10451    10488      +37     
- Misses       3764     3820      +56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

command-line options

The interpolation can be switched on for the three reconstructions
independently (energy, gammaness, direction)

By default the correction is applied. If no MC DL1 training
directory is provided, the path will be built from the path
of the RF models. If directory does not exist the option is
simply deactivated
@vuillaut
Copy link
Member

Hi @moralejo
Thank you for making this implementation.
Early feedback:
would it be possible to add the training and testing nodes of the current production as an ascii file in the lstchain data files to allow for testing without necessarily being on the cluster?
(astropy tables can be dumped to ascii easily)
I completely agree these pointing nodes should be saved with the models during training and then loaded from there in the future.

@moralejo
Copy link
Collaborator Author

Hi @moralejo Thank you for making this implementation. Early feedback: would it be possible to add the training and testing nodes of the current production as an ascii file in the lstchain data files to allow for testing without necessarily being on the cluster? (astropy tables can be dumped to ascii easily)

Will do. What is better, just the zenith and azimuth values, or a list of the directory names?

@vuillaut
Copy link
Member

Hi @moralejo Thank you for making this implementation. Early feedback: would it be possible to add the training and testing nodes of the current production as an ascii file in the lstchain data files to allow for testing without necessarily being on the cluster? (astropy tables can be dumped to ascii easily)

Will do. What is better, just the zenith and azimuth values, or a list of the directory names?

I think the table of values that you can use directly at inference would be great (with appropriate metadata such as the date of export).

@moralejo

This comment was marked as resolved.

@moralejo

This comment was marked as outdated.

@moralejo moralejo marked this pull request as ready for review November 29, 2024 14:58
Instead of closest angular distance we now take the closest nodes in alt_tel
on the same side of the culmination (same sign of sin_az_tel)
@moralejo moralejo requested a review from vuillaut December 3, 2024 14:16
@vuillaut vuillaut requested a review from Copilot December 11, 2024 14:26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 3 changed files in this pull request and generated no suggestions.

Files not reviewed (1)
  • lstchain/data/lstchain_standard_config.json: Language not supported
Comments skipped due to low confidence (1)

lstchain/reco/dl1_to_dl2.py:215

  • The word 'dictionnary' is misspelled. It should be 'dictionary'.
config: dictionnary containing configuration
@vuillaut

This comment was marked as resolved.

lstchain/data/lstchain_standard_config.json Outdated Show resolved Hide resolved
lstchain/scripts/lstchain_dl1_to_dl2.py Outdated Show resolved Hide resolved
morcuended

This comment was marked as resolved.

@morcuended

This comment was marked as resolved.

@moralejo
Copy link
Collaborator Author

moralejo commented Jan 23, 2025

  1. the training directions are saved as ascii files, produced automatically with the models. At inference this ascii file is loaded with the model to get training direction. But we could actually produce these ascii files manually for the current productions and add them to the models directories in the cluster to allow for interpolated inference already.

To save the pointing directions as ascii files, I'd recommend starting from astropy tables and save to ecsv

I have created the ECVS files for all directories of the new production, e.g.:
/fefs/aswg/data/models/AllSky/20240918_v0.10.12_allsky_nsb_tuning_0.00/dec_4822/training_dirs.ecsv
Please check if this is ok, I will change the code to use these (update: already done!).

morcuended
morcuended previously approved these changes Jan 24, 2025
Copy link
Member

@morcuended morcuended left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. I've just left some modifications on the docstrings following the numpydocs standard so it is later properly render in the documentation.

lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/scripts/lstchain_dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
morcuended
morcuended previously approved these changes Jan 24, 2025
@moralejo
Copy link
Collaborator Author

Thanks @morcuended !
@vuillaut about the way to store and retrieve the training node pointings: is that ok? Can we merge?

@morcuended
Copy link
Member

about the way to store and retrieve the training node pointings: is that ok? Can we merge?

From my side this is fine. Maybe for the future productions this file should be produced by lstmcpipe?

One of these files, could even be included in lstchain test dataset for unit testing.

@moralejo
Copy link
Collaborator Author

about the way to store and retrieve the training node pointings: is that ok? Can we merge?

From my side this is fine. Maybe for the future productions this file should be produced by lstmcpipe?

yes, that is the idea.

One of these files, could even be included in lstchain test dataset for unit testing.

For this we would need to store also RFs trained with several pointings. Is that the case now?

Copy link
Member

@morcuended morcuended left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left one last comment.

For this we would need to store also RFs trained with several pointings. Is that the case now?

No, right now dummy models are created from the test gamma MC, with single pointing

lstchain/reco/dl1_to_dl2.py Outdated Show resolved Hide resolved
@moralejo
Copy link
Collaborator Author

I left one last comment.

For this we would need to store also RFs trained with several pointings. Is that the case now?

No, right now dummy models are created from the test gamma MC, with single pointing

Ok, then we cannot introduce a unit test now. This is more than two months old, we need to move forward...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants